home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: H E L P
- Date: 3 Apr 1996 14:42:25 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4ju2oh$pli@news.xs4all.nl>
- References: <N.040296.013047.18@DynamicPPP-185.HIP.CAM.ORG>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- ramrod@cam.org writes:
-
- >Could anyone please tell me how to write the following program.
- >Using nested looping, the output is supposed to look like this.
-
- >Please enter your age in years (0 to end the program): 10
- >Happy Birthday To You
- >You are 10 Years Old
-
- >\x01\x01\x01\x01\x01\x01\x0\x01\x01\x01(ten happy faces)
-
- >The part that I am having a hard time with is the part that
- >whatever number I enter for the age, I'm supposed to get the same number
- >of happy faces, automatically. For example If I say I am 45 years old,
- >then the program should show 45 happy faces.
-
- int main()
- { int i,n;
-
- printf("How old are you: ");
- fflush(stdout); /* make sure prompt is displayed */
- scanf("%d",&n); /* get a number */
-
- if(n<1 || n>75) /* added this test as a bonus */
- { printf("No you're not!\n");
- return 1; } /* return with error=1 */
-
- printf("Hurray, %d years old today!\n\n",n);
-
- for(i=0;i<n;i++) /* now print the faces */
- putchar('\x01');
-
- return 0; /* return to OS without error */
- }
-
- Falstaff
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-